package com.cskaoyan.controller.admin.marketmanagement;

import com.cskaoyan.bean.MarketIssue;
import com.cskaoyan.bean.bo.admin.issue.IssueCreateBo;
import com.cskaoyan.bean.bo.admin.issue.IssueListBo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.admin.issue.IssueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Aaliyah
 * @date 2022/9/7 17:54
 * @description: 处理通用问题模块的请求
 */
@RestController
@RequestMapping("/admin/issue")
public class IssueController {

    @Autowired
    IssueService issueService;

    /**
     * @description: /admin/issue/list 请求的处理
     * @date: 2022/9/7 18:08
     * @param: [issueListBo] 封装了查询条件和分页信息
     */
    @RequestMapping("list")
    public BaseRespVo<CommonData<MarketIssue>> issueList(IssueListBo issueListBo){
        return BaseRespVo.ok(issueService.issueList(issueListBo));
    }

    /**
     * @description: /admin/issue/create 请求的处理
     * @date: 2022/9/7 20:05
     * @param: [issueCreateBo] 封装了新增的问答信息
     */
    @RequestMapping("create")
    public BaseRespVo<MarketIssue> issueCreate(@RequestBody IssueCreateBo issueCreateBo) {
        return BaseRespVo.ok(issueService.issueCreate(issueCreateBo));
    }

    /**
     * @description: /admin/issue/update 请求的处理
     * @date: 2022/9/7 21:51
     * @param: [marketIssue] 封装了完整的修改后的问答信息
     */
    @RequestMapping("update")
    public BaseRespVo issueUpdate(@RequestBody MarketIssue marketIssue) {
        issueService.issueUpdate(marketIssue);
        return BaseRespVo.ok(null);
    }

    /**
     * @description: /admin/issue/create 请求的处理
     * @date: 2022/9/7 21:23
     * @param: [marketIssue] 封装了需要删除的问答的信息
     */
    @RequestMapping("delete")
    public BaseRespVo issueDelete(@RequestBody MarketIssue marketIssue) {
        issueService.issueDelete(marketIssue);
        return BaseRespVo.ok(null);
    }

}
